# ProjectName: impls
# Author: chenmh
# DATE: 2023/10/31 13:54
# DESCRIBE: 机器学习算法实现的辅助工具类
# VERSION: 1.0

import numpy as np


class DataSet:
    def __init__(self, num_features, num_samples):
        '''

        :param num_features: 特征数量
        :param num_samples: 样本个数
        '''
        self.num_samples = num_samples
        self.num_features = num_features

    def gene_data(self):
        raise NotImplementedError


class RegressionDataSet(DataSet):
    def gene_data(self):
        x = np.random.normal(size=(self.num_samples, self.num_features))
        w = np.asarray([np.random.randint(10) for i in range(self.num_features)]).reshape(self.num_features, -1)
        b = np.random.uniform(size=(self.num_samples, 1)) * 5
        labels = x.dot(w) + b
        return x, w, b, labels


class ClassifyDataSet(DataSet):
    def gene_data(self):
        pass


class Evaluate:
    def __init__(self, true_value, predict_value):
        self.true_value = true_value
        self.predict_value = predict_value

    def accuracy(self):
        raise NotImplementedError


class RegressionEvaluate(Evaluate):

    def accuracy(self):
        return np.mean(np.abs(self.predict_value - self.true_value))
